#include "Interfaces/ITexture.h"

namespace gname
{
	PixelFormat GetTexturePixelFormat(TextureInternalFormat frmt)
	{
		if(frmt == TIF_ALPHA8 || frmt == TIF_ALPHA_FLOAT16 || frmt ==TIF_ALPHA_FLOAT32)
		{
			return PF_ALPHA;
		}

		 if(frmt == TIF_LUMINANCE8 || frmt == TIF_LUMINANCE_FLOAT16 || frmt ==TIF_LUMINANCE_FLOAT32)
		{
			return PF_LUMINANCE;
		}

		  if(frmt ==  TIF_LUMINANCE8_ALPHA8 || frmt ==  TIF_LUMINANCE_ALPHA_FLOAT16 || frmt ==TIF_LUMINANCE_ALPHA_FLOAT32)
		{
			return PF_LUMINANCE_ALPHA;
		}

		 if(frmt ==  TIF_RGB8  || frmt ==  TIF_RGB_FLOAT16  || frmt ==TIF_RGB_FLOAT32  || frmt ==PF_BGR_EXT )
		{
			return PF_RGB;
		}

		 if(frmt ==  TIF_RGBA8   || frmt ==   TIF_RGBA_FLOAT16    || frmt ==TIF_RGBA_FLOAT32)
		{
			return PF_RGBA;
		}

		 if(frmt ==  TIF_DEPTH_COMPONENT16  || frmt ==   TIF_DEPTH_COMPONENT24    || frmt ==TIF_DEPTH_COMPONENT32)
		{
			return PF_DEPTH;
		}

		

	  return PF_RGBA;
	}

	ITexture::ITexture( int w, int h,TextureInternalFormat format, int mipLevels,TexType  t = TTYPE_UNSIGNED_BYTE)
	{
		width  = w;
		height = h;

		data    = 0;
		id      = 0;
		texUnit = 0;
		type    = t;
		sampler = 0;
		
		levels = mipLevels;
		
		internFormat = format;
		SetTexturePixFormat(format);
		
		
		
		if(mipLevels > 0)
			mipmap = true;
	}



}
	
